Jump Game
August 23, 2016
This one was a bit tricky. I kept track of the maximum index we could jump, and if it ever exceeded the size of the array, we return true.
Full Solution in Java:
public class Solution { public boolean canJump(int[] nums) { int ind = nums[0]; for(int i=0; i< nums.length; i++){ if(ind>=nums.length-1){ return true; } if(i==ind && nums[i]==0){ return false; } if(i+nums[i]>ind){ ind = i+nums[i]; } } return false; } }